package com.googlecode.skald.client.cmds;

import com.googlecode.skald.client.Server;

/**
 * A Command to send the given text to the server as a cmd (game command).
 * 
 * @author Zach Tomaszewski
 */
public class SendCmd implements AffordanceCommand {

  private String cmd;
  
  /**
   * Constructs a SendCmd with the given cmd text to send.
   */
  public SendCmd(String cmdText) {
    this.cmd = cmdText;
  }
  
  /** Returns this SendCmd's contained cmd text. */
  public String getCmd() {
    return this.cmd; 
  }
  
  /**
   * Calls {@link Server#sendCmd} with this SendCmd's text.
   */
  @Override
  public void execute() {
    Server.sendCmd(this.cmd);
  }

  /** Any SendCmd can also act as a builder for more (different) SendCmds. */
  @Override
  public AffordanceCommand build(String cmdText) {    
    return new SendCmd(cmdText);
  }
}
